Open
Conversation
Add BLE advertisement parser and device registration for the SwitchBot Weather Station. Parses temperature, humidity, and battery from broadcast data. Includes unit tests for active and passive advertisement parsing. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
Add tests for service-data-only path, zero-data guard, and short manufacturer data. Remove unused devices/weather_station.py stub. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds SwitchBot Weather Station BLE advertisement support by introducing a dedicated parser, registering the new model in the supported-type map, and validating behavior via new advertisement parsing tests.
Changes:
- Add
SwitchbotModel.WEATHER_STATIONand register Weather Station model bytes inSUPPORTED_TYPES. - Introduce
process_weather_stationadvertisement parser to decode temperature/humidity/battery. - Add active/passive/service-data-only/empty-data test cases for Weather Station advertisements.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
tests/test_adv_parser.py |
Adds Weather Station parsing test coverage for multiple advertisement shapes. |
switchbot/const/__init__.py |
Introduces WEATHER_STATION in SwitchbotModel. |
switchbot/adv_parsers/weather_station.py |
Implements Weather Station adv payload decoding logic. |
switchbot/adv_parser.py |
Registers Weather Station parser + model identifiers in SUPPORTED_TYPES. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+32
to
+39
| if not temp_data: | ||
| temp_data = data[3:6] | ||
| if battery is None: | ||
| battery = data[2] & 0b01111111 | ||
|
|
||
| if not temp_data: | ||
| return {} | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add support for the SwitchBot Weather Station BLE device, a sensor device that broadcasts temperature, humidity, and battery level via BLE advertisements.
Changes
Features
SwitchbotModel.WEATHER_STATIONenum value0x00 0x10 0x53 0xB0(normal) and0x01 0x10 0x53 0xB0(pairing)Parser
process_weather_stationadvertisement parser inswitchbot/adv_parsers/weather_station.pymfr_data[7], temp/humidity atmfr_data[8:11]Tests